//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.batch;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.jpgolay.gui.date.DateComboBox;
import org.jpgolay.me.util.MEDate;
import org.jpgolay.me.util.MEUtility;

// Referenced classes of package org.jpgolay.me.batch:
//            Messages
public class BatchPanel extends JPanel {

    public BatchPanel() {
        jPanel = null;
        lastUpdateUserLabel = null;
        lastUpdateTimeLabel = null;
        idLabel = null;
        agencyIdLabel = null;
        agencyIdTextField = null;
        inputStockDateLabel = null;
        inputStockDateTextField = null;
        deliveryFormLabel = null;
        deliveryFormTextField = null;
        truckingCompanyLabel = null;
        truckingCompanyTextField = null;
        supplierGLNLabel = null;
        supplierGLNTextField = null;
        supplierIDLabel = null;
        supplierIDTextField = null;
        palletGTINLabel = null;
        palletGTINTextField = null;
        boxGTINLabel = null;
        boxGTINTextField = null;
        buyIdLabel = null;
        buyIdTextField = null;
        statusLabel = null;
        statusTextField = null;
        sSCCLabel = null;
        sSCCTextField = null;
        itemGTINLabel = null;
        itemGTINTextField = null;
        itemIdLabel = null;
        itemIdTextField = null;
        itemBatchLabel = null;
        itemBatchTextField = null;
        batchPriceLabel = null;
        batchPriceTextField = null;
        dLCLabel = null;
        dLCTextField = null;
        dLUOLabel = null;
        dLUOTextField = null;
        packagingLabel = null;
        packagingTextField = null;
        unitLabel = null;
        unitTextField = null;
        notesLabel = null;
        notesTextField = null;
        inputStockQuantityLabel = null;
        inputStockQuantityTextField = null;
        inventoryDateLabel = null;
        inventoryDateTextField = null;
        stockQuantityLabel = null;
        stockQuantityTextField = null;
        deltaInventoryLabel = null;
        deltaInventoryTextField = null;
        agencyId = 0;
        inputStockDate = null;
        deliveryForm = null;
        truckingCompany = null;
        supplierGLN = null;
        supplierID = null;
        palletGTIN = null;
        boxGTIN = null;
        buyId = null;
        status = 0;
        sSCC = null;
        itemGTIN = null;
        itemId = null;
        itemBatch = null;
        batchPrice = null;
        dLC = null;
        dLUO = null;
        packaging = null;
        unit = null;
        notes = null;
        inputStockQuantity = null;
        inventoryDate = null;
        stockQuantity = null;
        deltaInventory = null;
        lastUpdateUser = null;
        lastUpdateTime = null;
        id = null;
        jPanel1 = null;
        jPanel2 = null;
        jPanel3 = null;
        jPanel4 = null;
        jPanel5 = null;
        initialize();
    }

    private void initialize() {
        setLayout(new FlowLayout());
        setSize(340, 344);
        add(getJPanel(), null);
    }

    private JPanel getJPanel() {
        if (jPanel == null) {
            JLabel lastUpdateUserLabel = new JLabel();
            JLabel lastUpdateTimeLabel = new JLabel();
            JLabel idLabel = new JLabel();
            jPanel = new JPanel();
            jPanel.setLayout(null);
            jPanel.setPreferredSize(new Dimension(330, 334));
            jPanel.setBackground(new Color(0, 0, 153));
            jPanel.add(getJPanel1(), null);
            jPanel.add(getJPanel2(), null);
            jPanel.add(getJPanel3(), null);
            jPanel.add(getJPanel5(), null);
            jPanel.add(getJPanel4(), null);
        }
        return jPanel;
    }

    private JPanel getJPanel1() {
        if (jPanel1 == null) {
            jPanel1 = new JPanel();
            FlowLayout flowLayout1 = new FlowLayout();
            jPanel1.setLayout(flowLayout1);
            jPanel1.setPreferredSize(new Dimension(1, 1));
            jPanel1.setBackground(new Color(255, 255, 120));
            jPanel1.setSize(326, 26);
            jPanel1.setLocation(2, 2);
            flowLayout1.setHgap(2);
            flowLayout1.setVgap(2);
            jPanel1.add(getAgencyIdLabel(), null);
            jPanel1.add(getAgencyIdTextField(), null);
            jPanel1.add(getInputStockDateLabel(), null);
            jPanel1.add(getInputStockDateTextField(), null);
        }
        return jPanel1;
    }

    private JPanel getJPanel2() {
        if (jPanel2 == null) {
            jPanel2 = new JPanel();
            FlowLayout flowLayout2 = new FlowLayout();
            jPanel2.setLayout(flowLayout2);
            jPanel2.setBackground(new Color(255, 255, 140));
            jPanel2.setSize(326, 50);
            jPanel2.setLocation(2, 30);
            flowLayout2.setHgap(2);
            flowLayout2.setVgap(2);
            jPanel2.add(getDeliveryFormLabel(), null);
            jPanel2.add(getDeliveryFormTextField(), null);
            jPanel2.add(getTruckingCompanyLabel(), null);
            jPanel2.add(getTruckingCompanyTextField(), null);
            jPanel2.add(getSupplierGLNLabel(), null);
            jPanel2.add(getSupplierGLNTextField(), null);
            jPanel2.add(getSupplierIDLabel(), null);
            jPanel2.add(getSupplierIDTextField(), null);
        }
        return jPanel2;
    }

    private JPanel getJPanel3() {
        if (jPanel3 == null) {
            jPanel3 = new JPanel();
            FlowLayout flowLayout3 = new FlowLayout();
            jPanel3.setLayout(flowLayout3);
            jPanel3.setBackground(new Color(255, 255, 160));
            jPanel3.setSize(326, 26);
            jPanel3.setLocation(2, 82);
            flowLayout3.setHgap(2);
            flowLayout3.setVgap(2);
            jPanel3.add(getSSCCLabel(), null);
            jPanel3.add(getSSCCTextField(), null);
            jPanel3.add(getPalletGTINLabel(), null);
            jPanel3.add(getPalletGTINTextField(), null);
        }
        return jPanel3;
    }

    private JPanel getJPanel4() {
        if (jPanel4 == null) {
            jPanel4 = new JPanel();
            FlowLayout flowLayout4 = new FlowLayout();
            jPanel4.setLayout(flowLayout4);
            jPanel4.setBackground(new Color(255, 255, 200));
            jPanel4.setSize(326, 50);
            jPanel4.setLocation(2, 282);
            flowLayout4.setHgap(2);
            flowLayout4.setVgap(2);
            jPanel4.add(getStockQuantityLabel(), null);
            jPanel4.add(getStockQuantityTextField(), null);
            jPanel4.add(getDeltaInventoryLabel(), null);
            jPanel4.add(getDeltaInventoryTextField(), null);
            jPanel4.add(getInventoryDateLabel(), null);
            jPanel4.add(getInventoryDateTextField(), null);
            jPanel4.add(getIdLabel(), null);
            jPanel4.add(getLastUpdateTimeLabel(), null);
            jPanel4.add(getLastUpdateUserLabel(), null);
        }
        return jPanel4;
    }

    private JPanel getJPanel5() {
        if (jPanel5 == null) {
            jPanel5 = new JPanel();
            FlowLayout flowLayout5 = new FlowLayout();
            jPanel5.setLayout(flowLayout5);
            jPanel5.setBackground(new Color(255, 255, 180));
            jPanel5.setSize(326, 170);
            jPanel5.setLocation(2, 110);
            jPanel5.setPreferredSize(new Dimension(326, 170));
            flowLayout5.setHgap(2);
            flowLayout5.setVgap(2);
            jPanel5.add(getBuyIdLabel(), null);
            jPanel5.add(getBuyIdTextField(), null);
            jPanel5.add(getStatusLabel(), null);
            jPanel5.add(getStatusTextField(), null);
            jPanel5.add(getItemGTINLabel(), null);
            jPanel5.add(getItemGTINTextField(), null);
            jPanel5.add(getItemIdLabel(), null);
            jPanel5.add(getItemIdTextField(), null);
            jPanel5.add(getItemBatchLabel(), null);
            jPanel5.add(getItemBatchTextField(), null);
            jPanel5.add(getBatchPriceLabel(), null);
            jPanel5.add(getBatchPriceTextField(), null);
            jPanel5.add(getBoxGTINLabel(), null);
            jPanel5.add(getBoxGTINTextField(), null);
            jPanel5.add(getInputStockQuantityLabel(), null);
            jPanel5.add(getInputStockQuantityTextField(), null);
            jPanel5.add(getDLCLabel(), null);
            jPanel5.add(getDLCTextField(), null);
            jPanel5.add(getDLUOLabel(), null);
            jPanel5.add(getDLUOTextField(), null);
            jPanel5.add(getPackagingLabel(), null);
            jPanel5.add(getPackagingTextField(), null);
            jPanel5.add(getUnitLabel(), null);
            jPanel5.add(getUnitTextField(), null);
            jPanel5.add(getNotesLabel(), null);
            jPanel5.add(getNotesTextField(), null);
        }
        return jPanel5;
    }

    private JLabel getIdLabel() {
        if (idLabel == null) {
            idLabel = new JLabel();
            idLabel.setText(Messages.getString("BatchPanel.id"));
            idLabel.setPreferredSize(new Dimension(40, 22));
            idLabel.setHorizontalAlignment(0);
            String s = "<html>Identifiant unique du lot<br>interne \340 JGestCom.</html>";
            idLabel.setToolTipText(s);
            idLabel.setFont(new Font("Dialog", 0, 10));
        }
        return idLabel;
    }

    private JLabel getLastUpdateTimeLabel() {
        if (lastUpdateTimeLabel == null) {
            lastUpdateTimeLabel = new JLabel();
            lastUpdateTimeLabel.setText(Messages.getString("BatchPanel.time"));
            lastUpdateTimeLabel.setPreferredSize(new Dimension(68, 22));
            lastUpdateTimeLabel.setHorizontalAlignment(0);
            String s = "<html>Date de la derni\350re<br>modification du lot.</html>";
            lastUpdateTimeLabel.setToolTipText(s);
            lastUpdateTimeLabel.setFont(new Font("Dialog", 0, 10));
        }
        return lastUpdateTimeLabel;
    }

    private JLabel getLastUpdateUserLabel() {
        if (lastUpdateUserLabel == null) {
            lastUpdateUserLabel = new JLabel();
            lastUpdateUserLabel.setText(Messages.getString("BatchPanel.user"));
            lastUpdateUserLabel.setPreferredSize(new Dimension(50, 22));
            lastUpdateUserLabel.setHorizontalAlignment(4);
            String s = "<html>Dernier utilisateur<br>ayant modifi\351 ce lot.</html>";
            lastUpdateUserLabel.setToolTipText(s);
            lastUpdateUserLabel.setFont(new Font("Dialog", 0, 10));
        }
        return lastUpdateUserLabel;
    }

    private JLabel getAgencyIdLabel() {
        if (agencyIdLabel == null) {
            agencyIdLabel = new JLabel();
            agencyIdLabel.setText(Messages.getString("BatchPanel.agency"));
            agencyIdLabel.setPreferredSize(new Dimension(60, 22));
            agencyIdLabel.setToolTipText("Agence r\351ceptionnant le produit");
        }
        return agencyIdLabel;
    }

    private JLabel getInputStockDateLabel() {
        if (inputStockDateLabel == null) {
            inputStockDateLabel = new JLabel();
            inputStockDateLabel.setText(Messages.getString("BatchPanel.inputStockDate"));
            inputStockDateLabel.setPreferredSize(new Dimension(60, 22));
            inputStockDateLabel.setToolTipText("Date d'entr\351e en stock du lot");
        }
        return inputStockDateLabel;
    }

    private JLabel getDeliveryFormLabel() {
        if (deliveryFormLabel == null) {
            deliveryFormLabel = new JLabel();
            deliveryFormLabel.setText(Messages.getString("BatchPanel.deliveryForm"));
            deliveryFormLabel.setPreferredSize(new Dimension(60, 22));
            deliveryFormLabel.setToolTipText("Bulletin de livraison du fournisseur");
        }
        return deliveryFormLabel;
    }

    private JLabel getTruckingCompanyLabel() {
        if (truckingCompanyLabel == null) {
            truckingCompanyLabel = new JLabel();
            truckingCompanyLabel.setText(Messages.getString("BatchPanel.truckingCompany"));
            truckingCompanyLabel.setPreferredSize(new Dimension(60, 22));
            truckingCompanyLabel.setToolTipText("Nom de la compagnie de transport");
        }
        return truckingCompanyLabel;
    }

    private JLabel getSupplierGLNLabel() {
        if (supplierGLNLabel == null) {
            supplierGLNLabel = new JLabel();
            supplierGLNLabel.setText(Messages.getString("BatchPanel.supplierGLN"));
            supplierGLNLabel.setPreferredSize(new Dimension(60, 22));
            supplierGLNLabel.setToolTipText("GLN du fournisseur");
        }
        return supplierGLNLabel;
    }

    private JLabel getSupplierIDLabel() {
        if (supplierIDLabel == null) {
            supplierIDLabel = new JLabel();
            supplierIDLabel.setText(Messages.getString("BatchPanel.supplierID"));
            supplierIDLabel.setPreferredSize(new Dimension(60, 22));
            supplierIDLabel.setToolTipText("Code du fournisseur (JGestCom)");
        }
        return supplierIDLabel;
    }

    private JLabel getPalletGTINLabel() {
        if (palletGTINLabel == null) {
            palletGTINLabel = new JLabel();
            palletGTINLabel.setText(Messages.getString("BatchPanel.palletGTIN"));
            palletGTINLabel.setPreferredSize(new Dimension(60, 22));
            palletGTINLabel.setToolTipText("Num\351ro GTIN de la palette");
        }
        return palletGTINLabel;
    }

    private JLabel getBoxGTINLabel() {
        if (boxGTINLabel == null) {
            boxGTINLabel = new JLabel();
            boxGTINLabel.setText(Messages.getString("BatchPanel.boxGTIN"));
            boxGTINLabel.setPreferredSize(new Dimension(60, 22));
            boxGTINLabel.setToolTipText("Num\351ro GTIN du carton");
        }
        return boxGTINLabel;
    }

    private JLabel getBuyIdLabel() {
        if (buyIdLabel == null) {
            buyIdLabel = new JLabel();
            buyIdLabel.setText(Messages.getString("BatchPanel.buyIdLabel"));
            buyIdLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Num\351ro du bon de commande<br>(JGestCom) correspondant.</html>";
            buyIdLabel.setToolTipText(s);
            buyIdLabel.setForeground(new Color(0, 0, 153));
        }
        return buyIdLabel;
    }

    private JLabel getStatusLabel() {
        if (statusLabel == null) {
            statusLabel = new JLabel();
            statusLabel.setText(Messages.getString("BatchPanel.status"));
            statusLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html><b>V\351rifi\351 \351gale :</b><br>Contr\364le quantitatif et<br>contr\364le qualitatif de<br>chaque produits.</html>";
            statusLabel.setToolTipText(s);
        }
        return statusLabel;
    }

    private JLabel getSSCCLabel() {
        if (sSCCLabel == null) {
            sSCCLabel = new JLabel();
            sSCCLabel.setText(Messages.getString("BatchPanel.sSCC"));
            sSCCLabel.setPreferredSize(new Dimension(60, 22));
            sSCCLabel.setToolTipText("Num\351ro s\351quentiel du colis");
        }
        return sSCCLabel;
    }

    private JLabel getItemGTINLabel() {
        if (itemGTINLabel == null) {
            itemGTINLabel = new JLabel();
            itemGTINLabel.setText(Messages.getString("BatchPanel.itemGTIN"));
            itemGTINLabel.setPreferredSize(new Dimension(60, 22));
            itemGTINLabel.setToolTipText("Code GTIN de l'article");
        }
        return itemGTINLabel;
    }

    private JLabel getItemIdLabel() {
        if (itemIdLabel == null) {
            itemIdLabel = new JLabel();
            itemIdLabel.setText(Messages.getString("BatchPanel.itemId"));
            itemIdLabel.setPreferredSize(new Dimension(60, 22));
            itemIdLabel.setToolTipText("R\351f\351rence interne de l'article");
            itemIdLabel.setForeground(new Color(0, 0, 153));
        }
        return itemIdLabel;
    }

    private JLabel getItemBatchLabel() {
        if (itemBatchLabel == null) {
            itemBatchLabel = new JLabel();
            itemBatchLabel.setText(Messages.getString("BatchPanel.itemBatch"));
            itemBatchLabel.setPreferredSize(new Dimension(60, 22));
            itemBatchLabel.setToolTipText("Num\351ro du lot");
        }
        return itemBatchLabel;
    }

    private JLabel getBatchPriceLabel() {
        if (batchPriceLabel == null) {
            batchPriceLabel = new JLabel();
            batchPriceLabel.setText(Messages.getString("BatchPanel.batchPrice"));
            batchPriceLabel.setPreferredSize(new Dimension(60, 22));
            batchPriceLabel.setHorizontalAlignment(10);
            batchPriceLabel.setToolTipText("Prix du lot");
        }
        return batchPriceLabel;
    }

    private JLabel getDLCLabel() {
        if (dLCLabel == null) {
            dLCLabel = new JLabel();
            dLCLabel.setText(Messages.getString("BatchPanel.dLC"));
            dLCLabel.setPreferredSize(new Dimension(60, 22));
            dLCLabel.setToolTipText("Date Limite de Consomation");
        }
        return dLCLabel;
    }

    private JLabel getDLUOLabel() {
        if (dLUOLabel == null) {
            dLUOLabel = new JLabel();
            dLUOLabel.setText(Messages.getString("BatchPanel.dLUO"));
            dLUOLabel.setPreferredSize(new Dimension(60, 22));
            dLUOLabel.setToolTipText("Date Limite d'Utilisation Optimale");
        }
        return dLUOLabel;
    }

    private JLabel getPackagingLabel() {
        if (packagingLabel == null) {
            packagingLabel = new JLabel();
            packagingLabel.setText(Messages.getString("BatchPanel.packaging"));
            packagingLabel.setPreferredSize(new Dimension(60, 22));
            packagingLabel.setToolTipText("Conditionnement");
        }
        return packagingLabel;
    }

    private JLabel getUnitLabel() {
        if (unitLabel == null) {
            unitLabel = new JLabel();
            unitLabel.setText(Messages.getString("BatchPanel.unit"));
            unitLabel.setPreferredSize(new Dimension(60, 22));
            unitLabel.setToolTipText("Unit\351 de conditionnement");
        }
        return unitLabel;
    }

    private JLabel getNotesLabel() {
        if (notesLabel == null) {
            notesLabel = new JLabel();
            notesLabel.setText(Messages.getString("BatchPanel.notes"));
            notesLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Information sur le produit re\347u<br>et ces conditions d'emballage</html>";
            notesLabel.setToolTipText(s);
        }
        return notesLabel;
    }

    private JLabel getInputStockQuantityLabel() {
        if (inputStockQuantityLabel == null) {
            inputStockQuantityLabel = new JLabel();
            inputStockQuantityLabel.setText(Messages.getString("BatchPanel.inputStockQuantity"));
            inputStockQuantityLabel.setPreferredSize(new Dimension(60, 22));
            String s = "<html>Quantit\351 entr\351e en stock.<br><font color=red><b>Champs obligatoire !</b></font></html>";
            inputStockQuantityLabel.setToolTipText(s);
            inputStockQuantityLabel.setForeground(new Color(0, 0, 153));
        }
        return inputStockQuantityLabel;
    }

    private JLabel getInventoryDateLabel() {
        if (inventoryDateLabel == null) {
            inventoryDateLabel = new JLabel();
            inventoryDateLabel.setText(Messages.getString("BatchPanel.inventoryDate"));
            inventoryDateLabel.setPreferredSize(new Dimension(60, 22));
            inventoryDateLabel.setToolTipText("Date du dernier inventaire");
        }
        return inventoryDateLabel;
    }

    private JLabel getStockQuantityLabel() {
        if (stockQuantityLabel == null) {
            stockQuantityLabel = new JLabel();
            stockQuantityLabel.setText(Messages.getString("BatchPanel.stockQuantity"));
            stockQuantityLabel.setPreferredSize(new Dimension(60, 22));
            stockQuantityLabel.setToolTipText("Stock r\351el");
        }
        return stockQuantityLabel;
    }

    private JLabel getDeltaInventoryLabel() {
        if (deltaInventoryLabel == null) {
            deltaInventoryLabel = new JLabel();
            deltaInventoryLabel.setText(Messages.getString("BatchPanel.deltaInventory"));
            deltaInventoryLabel.setPreferredSize(new Dimension(60, 22));
            deltaInventoryLabel.setToolTipText("Stock physique");
        }
        return deltaInventoryLabel;
    }

    private JComboBox getAgencyIdTextField() {
        if (agencyIdTextField == null) {
            agencyIdTextField = new JComboBox();
            agencyIdTextField.setPreferredSize(new Dimension(98, 22));
            agencyIdTextField.setToolTipText("Agence r\351ceptionnant le produit");
            agencyIdTextField.setModel(new DefaultComboBoxModel(new String[]{
                        "Agence 1", "Agence 2", "Agence 3", "Agence 4", "Agence 5"
                    }));
            agencyIdTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setAgencyId(agencyIdTextField.getSelectedIndex() + 1);
                }
            });
        }
        return agencyIdTextField;
    }

    private DateComboBox getInputStockDateTextField() {
        if (inputStockDateTextField == null) {
            inputStockDateTextField = new DateComboBox();
            inputStockDateTextField.setPreferredSize(new Dimension(98, 22));
            inputStockDateTextField.setToolTipText("Date d'entr\351e en stock du lot");
            inputStockDateTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setInputStockDate((String) inputStockDateTextField.getSelectedItem());
                }
            });
        }
        return inputStockDateTextField;
    }

    private JTextField getDeliveryFormTextField() {
        if (deliveryFormTextField == null) {
            deliveryFormTextField = new JTextField();
            deliveryFormTextField.setPreferredSize(new Dimension(98, 22));
            deliveryFormTextField.setHorizontalAlignment(0);
            deliveryFormTextField.setToolTipText("Bulletin de livraison du fournisseur");
            deliveryFormTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setDeliveryForm(deliveryFormTextField.getText());
                }
            });
        }
        return deliveryFormTextField;
    }

    private JTextField getTruckingCompanyTextField() {
        if (truckingCompanyTextField == null) {
            truckingCompanyTextField = new JTextField();
            truckingCompanyTextField.setPreferredSize(new Dimension(98, 22));
            truckingCompanyTextField.setHorizontalAlignment(0);
            truckingCompanyTextField.setToolTipText("Nom de la compagnie de transport");
            truckingCompanyTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setTruckingCompany(truckingCompanyTextField.getText());
                }
            });
        }
        return truckingCompanyTextField;
    }

    private JTextField getSupplierGLNTextField() {
        if (supplierGLNTextField == null) {
            supplierGLNTextField = new JTextField();
            supplierGLNTextField.setPreferredSize(new Dimension(98, 22));
            supplierGLNTextField.setHorizontalAlignment(0);
            supplierGLNTextField.setToolTipText("GLN du fournisseur");
            supplierGLNTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setSupplierGLN(supplierGLNTextField.getText());
                }
            });
        }
        return supplierGLNTextField;
    }

    private JTextField getSupplierIDTextField() {
        if (supplierIDTextField == null) {
            supplierIDTextField = new JTextField();
            supplierIDTextField.setPreferredSize(new Dimension(98, 22));
            supplierIDTextField.setHorizontalAlignment(0);
            supplierIDTextField.setToolTipText("Code interne (jgestcom) du fournisseur");
            supplierIDTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setSupplierID(supplierIDTextField.getText());
                }
            });
        }
        return supplierIDTextField;
    }

    private JTextField getPalletGTINTextField() {
        if (palletGTINTextField == null) {
            palletGTINTextField = new JTextField();
            palletGTINTextField.setPreferredSize(new Dimension(98, 22));
            palletGTINTextField.setHorizontalAlignment(0);
            palletGTINTextField.setToolTipText("GTIN de la palette");
            palletGTINTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setPalletGTIN(palletGTINTextField.getText());
                }
            });
        }
        return palletGTINTextField;
    }

    private JTextField getBoxGTINTextField() {
        if (boxGTINTextField == null) {
            boxGTINTextField = new JTextField();
            boxGTINTextField.setPreferredSize(new Dimension(98, 22));
            boxGTINTextField.setHorizontalAlignment(0);
            boxGTINTextField.setToolTipText("Num\351ro GTIN du carton");
            boxGTINTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setBoxGTIN(boxGTINTextField.getText());
                }
            });
        }
        return boxGTINTextField;
    }

    private JTextField getBuyIdTextField() {
        if (buyIdTextField == null) {
            buyIdTextField = new JTextField();
            buyIdTextField.setPreferredSize(new Dimension(98, 22));
            buyIdTextField.setHorizontalAlignment(0);
            buyIdTextField.setForeground(new Color(0, 0, 153));
            buyIdTextField.setFont(new Font("Dialog", 1, 12));
            String s = "<html>Num\351ro du bon de commande<br>(JGestCom) correspondant.</html>";
            buyIdTextField.setToolTipText(s);
            buyIdTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setBuyId(buyIdTextField.getText());
                }
            });
        }
        return buyIdTextField;
    }

    private JComboBox getStatusTextField() {
        if (statusTextField == null) {
            statusTextField = new JComboBox();
            statusTextField.setPreferredSize(new Dimension(98, 22));
            String s = "<html><b>V\351rifi\351 \351gale :</b><br>Contr\364le quantitatif et<br>contr\364le qualitatif de<br>chaque produits.</html>";
            statusTextField.setToolTipText(s);
            statusTextField.setModel(new DefaultComboBoxModel(new String[]{
                        "Non v\351rifi\351", "V\351rifi\351"
                    }));
            statusTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setStatus(statusTextField.getSelectedIndex());
                }
            });
        }
        return statusTextField;
    }

    private JTextField getSSCCTextField() {
        if (sSCCTextField == null) {
            sSCCTextField = new JTextField();
            sSCCTextField.setPreferredSize(new Dimension(98, 22));
            sSCCTextField.setHorizontalAlignment(0);
            sSCCTextField.setToolTipText("Num\351ro s\351quentiel du colis");
            sSCCTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setSSCC(sSCCTextField.getText());
                }
            });
        }
        return sSCCTextField;
    }

    private JTextField getItemGTINTextField() {
        if (itemGTINTextField == null) {
            itemGTINTextField = new JTextField();
            itemGTINTextField.setPreferredSize(new Dimension(98, 22));
            itemGTINTextField.setHorizontalAlignment(0);
            itemGTINTextField.setToolTipText("Code GTIN de l'article");
            itemGTINTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setItemGTIN(itemGTINTextField.getText());
                }
            });
        }
        return itemGTINTextField;
    }

    private JTextField getItemIdTextField() {
        if (itemIdTextField == null) {
            itemIdTextField = new JTextField();
            itemIdTextField.setPreferredSize(new Dimension(98, 22));
            itemIdTextField.setHorizontalAlignment(0);
            itemIdTextField.setForeground(new Color(0, 0, 153));
            itemIdTextField.setToolTipText("R\351f\351rence interne de l'article");
            itemIdTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setItemId(itemIdTextField.getText());
                }
            });
        }
        return itemIdTextField;
    }

    private JTextField getItemBatchTextField() {
        if (itemBatchTextField == null) {
            itemBatchTextField = new JTextField();
            itemBatchTextField.setPreferredSize(new Dimension(98, 22));
            itemBatchTextField.setHorizontalAlignment(0);
            String s = "<html>Num\351ro du lot<br>double click pour<br>incr\351menter un num\351ro<br>interne \340 jgestcom.</html>";
            itemBatchTextField.setToolTipText(s);
            itemBatchTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setItemBatch(itemBatchTextField.getText());
                }
            });
        }
        return itemBatchTextField;
    }

    private JTextField getBatchPriceTextField() {
        if (batchPriceTextField == null) {
            batchPriceTextField = new JTextField();
            batchPriceTextField.setPreferredSize(new Dimension(98, 22));
            batchPriceTextField.setHorizontalAlignment(4);
            batchPriceTextField.setToolTipText("Prix du lot");
            batchPriceTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setBatchPrice(batchPriceTextField.getText());
                }
            });
        }
        return batchPriceTextField;
    }

    private DateComboBox getDLCTextField() {
        if (dLCTextField == null) {
            dLCTextField = new DateComboBox();
            dLCTextField.setPreferredSize(new Dimension(98, 22));
            dLCTextField.setToolTipText("Date Limite de Consomation");
            dLCTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setDLC((String) dLCTextField.getSelectedItem());
                }
            });
        }
        return dLCTextField;
    }

    private DateComboBox getDLUOTextField() {
        if (dLUOTextField == null) {
            dLUOTextField = new DateComboBox();
            dLUOTextField.setPreferredSize(new Dimension(98, 22));
            dLUOTextField.setToolTipText("Date Limite d'Utilisation Optimale");
            dLUOTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setDLUO((String) dLUOTextField.getSelectedItem());
                }
            });
        }
        return dLUOTextField;
    }

    private JComboBox getPackagingTextField() {
        if (packagingTextField == null) {
            packagingTextField = new JComboBox();
            packagingTextField.setPreferredSize(new Dimension(98, 22));
            packagingTextField.setToolTipText("Conditionnement");
            packagingTextField.setModel(new DefaultComboBoxModel(MEUtility.PACKAGING));
            packagingTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setPackaging((String) packagingTextField.getSelectedItem());
                }
            });
        }
        return packagingTextField;
    }

    private JComboBox getUnitTextField() {
        if (unitTextField == null) {
            unitTextField = new JComboBox();
            unitTextField.setPreferredSize(new Dimension(98, 22));
            unitTextField.setToolTipText("Unit\351 de conditionnement");
            unitTextField.setModel(new DefaultComboBoxModel(MEUtility.SALES_UNIT));
            unitTextField.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    setUnit((String) unitTextField.getSelectedItem());
                }
            });
        }
        return unitTextField;
    }

    private JTextField getNotesTextField() {
        if (notesTextField == null) {
            notesTextField = new JTextField();
            notesTextField.setPreferredSize(new Dimension(260, 22));
            String s = "<html>Information sur le produit re\347u<br>et ces conditions d'emballage</html>";
            notesTextField.setToolTipText(s);
            notesTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setNotes(notesTextField.getText());
                }
            });
        }
        return notesTextField;
    }

    private JTextField getInputStockQuantityTextField() {
        if (inputStockQuantityTextField == null) {
            inputStockQuantityTextField = new JTextField();
            inputStockQuantityTextField.setPreferredSize(new Dimension(98, 22));
            inputStockQuantityTextField.setHorizontalAlignment(4);
            inputStockQuantityTextField.setForeground(new Color(0, 0, 153));
            String s = "<html>Quantit\351 entr\351e en stock.<br><font color=red><b>Champs obligatoire !</b></font></html>";
            inputStockQuantityTextField.setToolTipText(s);
            inputStockQuantityTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setInputStockQuantity(inputStockQuantityTextField.getText());
                }
            });
        }
        return inputStockQuantityTextField;
    }

    private JTextField getInventoryDateTextField() {
        if (inventoryDateTextField == null) {
            inventoryDateTextField = new JTextField();
            inventoryDateTextField.setPreferredSize(new Dimension(98, 22));
            inventoryDateTextField.setEditable(false);
            inventoryDateTextField.setToolTipText("Date du dernier inventaire");
            inventoryDateTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setInventoryDate(inventoryDateTextField.getText());
                }
            });
        }
        return inventoryDateTextField;
    }

    private JTextField getStockQuantityTextField() {
        if (stockQuantityTextField == null) {
            stockQuantityTextField = new JTextField();
            stockQuantityTextField.setPreferredSize(new Dimension(98, 22));
            stockQuantityTextField.setEditable(false);
            stockQuantityTextField.setToolTipText("Stock r\351el");
            stockQuantityTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setStockQuantity(stockQuantityTextField.getText());
                }
            });
        }
        return stockQuantityTextField;
    }

    private JTextField getDeltaInventoryTextField() {
        if (deltaInventoryTextField == null) {
            deltaInventoryTextField = new JTextField();
            deltaInventoryTextField.setPreferredSize(new Dimension(98, 22));
            deltaInventoryTextField.setEditable(false);
            deltaInventoryTextField.setToolTipText("Stock physique");
            deltaInventoryTextField.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    setDeltaInventory(deltaInventoryTextField.getText());
                }
            });
        }
        return deltaInventoryTextField;
    }

    public JTextField getItemBatchJTextField() {
        return getItemBatchTextField();
    }

    public int getAgencyId() {
        return agencyId + 1;
    }

    public void setAgencyId(int agencyId) {
        if (agencyId - 1 != this.agencyId) {
            int old = this.agencyId;
            this.agencyId = agencyId - 1;
            firePropertyChange("agencyId", old, agencyId - 1);
            getAgencyIdTextField().setSelectedIndex(agencyId - 1);
        }
    }

    public String getBatchPrice() {
        return batchPrice;
    }

    public void setBatchPrice(String batchPrice) {
        String old = this.batchPrice;
        this.batchPrice = batchPrice;
        firePropertyChange("batchPrice", old, batchPrice);
        getBatchPriceTextField().setText(batchPrice);
    }

    public String getBoxGTIN() {
        return boxGTIN;
    }

    public void setBoxGTIN(String boxGTIN) {
        String old = this.boxGTIN;
        this.boxGTIN = boxGTIN;
        firePropertyChange("boxGTIN", old, boxGTIN);
        getBoxGTINTextField().setText(boxGTIN);
    }

    public String getBuyId() {
        return buyId;
    }

    public JTextField getBuyIdJTextField() {
        return getBuyIdTextField();
    }

    public void setBuyId(String buyId) {
        String old = this.buyId;
        this.buyId = buyId;
        firePropertyChange("buyId", old, buyId);
        getBuyIdTextField().setText(buyId);
    }

    public String getDeliveryForm() {
        return deliveryForm;
    }

    public void setDeliveryForm(String deliveryForm) {
        String old = this.deliveryForm;
        this.deliveryForm = deliveryForm;
        firePropertyChange("deliveryForm", old, deliveryForm);
        getDeliveryFormTextField().setText(deliveryForm);
    }

    public String getDeltaInventory() {
        return deltaInventory;
    }

    public void setDeltaInventory(String deltaInventory) {
        String old = deltaInventory;
        this.deltaInventory = deltaInventory;
        firePropertyChange("deltaInventory", old, deltaInventory);
        getDeltaInventoryTextField().setText(deltaInventory);
    }

    public String getDLC() {
        return dLC;
    }

    public void setDLC(String dLC) {
        String old = this.dLC;
        this.dLC = dLC;
        firePropertyChange("dLC", old, dLC);
        getDLCTextField().setModel(new DefaultComboBoxModel(new String[]{
                    dLC
                }));
    }

    public String getDLUO() {
        return dLUO;
    }

    public void setDLUO(String dLUO) {
        String old = this.dLUO;
        this.dLUO = dLUO;
        firePropertyChange("dLUO", old, dLUO);
        getDLUOTextField().setModel(new DefaultComboBoxModel(new String[]{
                    dLUO
                }));
    }

    public String getInputStockDate() {
        return inputStockDate;
    }

    public void setInputStockDate(String inputStockDate) {
        String old = this.inputStockDate;
        this.inputStockDate = inputStockDate;
        firePropertyChange("inputStockDate", old, inputStockDate);
        getInputStockDateTextField().setModel(new DefaultComboBoxModel(new String[]{
                    inputStockDate
                }));
    }

    public String getInputStockQuantity() {
        return inputStockQuantity;
    }

    public void setInputStockQuantity(String inputStockQuantity) {
        String old = this.inputStockQuantity;
        this.inputStockQuantity = inputStockQuantity;
        firePropertyChange("inputStockQuantity", old, inputStockQuantity);
        getInputStockQuantityTextField().setText(inputStockQuantity);
    }

    public String getInventoryDate() {
        return inventoryDate;
    }

    public void setInventoryDate(String inventoryDate) {
        String old = this.inventoryDate;
        this.inventoryDate = inventoryDate;
        firePropertyChange("inventoryDate", old, inventoryDate);
        getInventoryDateTextField().setText(inventoryDate);
    }

    public String getItemBatch() {
        return itemBatch;
    }

    public void setItemBatch(String itemBatch) {
        String old = this.itemBatch;
        this.itemBatch = itemBatch;
        firePropertyChange("itemBatch", old, itemBatch);
        getItemBatchTextField().setText(itemBatch);
    }

    public String getItemGTIN() {
        return itemGTIN;
    }

    public void setItemGTIN(String itemGTIN) {
        String old = this.itemGTIN;
        this.itemGTIN = itemGTIN;
        firePropertyChange("itemGTIN", old, itemGTIN);
        getItemGTINTextField().setText(itemGTIN);
    }

    public String getItemId() {
        return itemId;
    }

    public void setItemId(String itemId) {
        String old = this.itemId;
        this.itemId = itemId;
        firePropertyChange("itemId", old, itemId);
        getItemIdTextField().setText(itemId);
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        String old = this.notes;
        this.notes = notes;
        firePropertyChange("notes", old, notes);
        getNotesTextField().setText(notes);
    }

    public String getPackaging() {
        return packaging;
    }

    public void setPackaging(String packaging) {
        if (!packaging.equals(this.packaging)) {
            String old = this.packaging;
            this.packaging = packaging;
            firePropertyChange("packaging", old, packaging);
            getPackagingTextField().setSelectedItem(packaging);
        }
    }

    public String getPalletGTIN() {
        return palletGTIN;
    }

    public void setPalletGTIN(String palletGTIN) {
        String old = this.palletGTIN;
        this.palletGTIN = palletGTIN;
        firePropertyChange("palletGTIN", old, palletGTIN);
        getPalletGTINTextField().setText(palletGTIN);
    }

    public String getSSCC() {
        return sSCC;
    }

    public void setSSCC(String sSCC) {
        String old = this.sSCC;
        this.sSCC = sSCC;
        firePropertyChange("sSCC", old, sSCC);
        getSSCCTextField().setText(sSCC);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        if (status != this.status) {
            int old = this.status;
            this.status = status;
            firePropertyChange("status", old, status);
            getStatusTextField().setSelectedIndex(status);
        }
    }

    public String getStockQuantity() {
        return stockQuantity;
    }

    public void setStockQuantity(String stockQuantity) {
        String old = this.stockQuantity;
        this.stockQuantity = stockQuantity;
        firePropertyChange("stockQuantity", old, stockQuantity);
        getStockQuantityTextField().setText(stockQuantity);
    }

    public JTextField getInputStockQuantityJTextField() {
        return getInputStockQuantityTextField();
    }

    public String getSupplierGLN() {
        return supplierGLN;
    }

    public void setSupplierGLN(String supplierGLN) {
        String old = this.supplierGLN;
        this.supplierGLN = supplierGLN;
        firePropertyChange("supplierGLN", old, supplierGLN);
        getSupplierGLNTextField().setText(supplierGLN);
    }

    public String getSupplierID() {
        return supplierID;
    }

    public void setSupplierID(String supplierID) {
        String old = this.supplierID;
        this.supplierID = supplierID;
        firePropertyChange("supplierID", old, supplierID);
        getSupplierIDTextField().setText(supplierID);
    }

    public String getTruckingCompany() {
        return truckingCompany;
    }

    public void setTruckingCompany(String truckingCompany) {
        String old = this.truckingCompany;
        this.truckingCompany = truckingCompany;
        firePropertyChange("truckingCompany", old, truckingCompany);
        getTruckingCompanyTextField().setText(truckingCompany);
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        if (!unit.equals(this.unit)) {
            String old = this.unit;
            this.unit = unit;
            firePropertyChange("unit", old, unit);
            getUnitTextField().setSelectedItem(unit);
        }
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        String old = this.id;
        this.id = id;
        firePropertyChange("id", old, id);
        idLabel.setText(id);
    }

    public String getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(String lastUpdateTime) {
        String old = this.lastUpdateTime;
        this.lastUpdateTime = lastUpdateTime;
        firePropertyChange("lastUpdateTime", old, lastUpdateTime);
        lastUpdateTimeLabel.setText(lastUpdateTime);
    }

    public String getLastUpdateUser() {
        return lastUpdateUser;
    }

    public void setLastUpdateUser(String lastUpdateUser) {
        String old = this.lastUpdateUser;
        this.lastUpdateUser = lastUpdateUser;
        firePropertyChange("lastUpdateUser", old, lastUpdateUser);
        lastUpdateUserLabel.setText(lastUpdateUser);
    }

    public void cleanField(boolean all) {
        if (all) {
            setAgencyId(1);
            deliveryFormTextField.setText("");
            truckingCompanyTextField.setText("");
            supplierGLNTextField.setText("");
            supplierIDTextField.setText("");
            palletGTINTextField.setText("");
            sSCCTextField.setText("");
            inputStockDate = (new MEDate()).getPlain();
            inputStockDateTextField.setModel(new DefaultComboBoxModel(new String[]{
                        inputStockDate
                    }));
            deliveryForm = null;
            truckingCompany = null;
            supplierGLN = null;
            supplierID = null;
            palletGTIN = null;
            sSCC = null;
        }
        boxGTINTextField.setText("");
        buyIdTextField.setText("");
        setStatus(0);
        itemGTINTextField.setText("");
        itemIdTextField.setText("");
        itemBatchTextField.setText("");
        batchPriceTextField.setText("");
        dLCTextField.setModel(new DefaultComboBoxModel(new String[]{
                    ""
                }));
        dLUOTextField.setModel(new DefaultComboBoxModel(new String[]{
                    ""
                }));
        setPackaging("1");
        setUnit("pi\350ce");
        notesTextField.setText("");
        inputStockQuantityTextField.setText("");
        inventoryDateTextField.setText("");
        stockQuantityTextField.setText("");
        deltaInventoryTextField.setText("");
        lastUpdateUserLabel.setText("");
        lastUpdateTimeLabel.setText("");
        idLabel.setText("");
        boxGTIN = null;
        buyId = null;
        itemGTIN = null;
        itemId = null;
        itemBatch = null;
        batchPrice = null;
        dLC = null;
        dLUO = null;
        notes = null;
        inputStockQuantity = null;
        inventoryDate = null;
        stockQuantity = null;
        deltaInventory = null;
        lastUpdateUser = null;
        lastUpdateTime = null;
        id = null;
    }
    private JPanel jPanel;
    private JLabel lastUpdateUserLabel;
    private JLabel lastUpdateTimeLabel;
    private JLabel idLabel;
    private JLabel agencyIdLabel;
    private JComboBox agencyIdTextField;
    private JLabel inputStockDateLabel;
    private DateComboBox inputStockDateTextField;
    private JLabel deliveryFormLabel;
    private JTextField deliveryFormTextField;
    private JLabel truckingCompanyLabel;
    private JTextField truckingCompanyTextField;
    private JLabel supplierGLNLabel;
    private JTextField supplierGLNTextField;
    private JLabel supplierIDLabel;
    private JTextField supplierIDTextField;
    private JLabel palletGTINLabel;
    private JTextField palletGTINTextField;
    private JLabel boxGTINLabel;
    private JTextField boxGTINTextField;
    private JLabel buyIdLabel;
    private JTextField buyIdTextField;
    private JLabel statusLabel;
    private JComboBox statusTextField;
    private JLabel sSCCLabel;
    private JTextField sSCCTextField;
    private JLabel itemGTINLabel;
    private JTextField itemGTINTextField;
    private JLabel itemIdLabel;
    private JTextField itemIdTextField;
    private JLabel itemBatchLabel;
    private JTextField itemBatchTextField;
    private JLabel batchPriceLabel;
    private JTextField batchPriceTextField;
    private JLabel dLCLabel;
    private DateComboBox dLCTextField;
    private JLabel dLUOLabel;
    private DateComboBox dLUOTextField;
    private JLabel packagingLabel;
    private JComboBox packagingTextField;
    private JLabel unitLabel;
    private JComboBox unitTextField;
    private JLabel notesLabel;
    private JTextField notesTextField;
    private JLabel inputStockQuantityLabel;
    private JTextField inputStockQuantityTextField;
    private JLabel inventoryDateLabel;
    private JTextField inventoryDateTextField;
    private JLabel stockQuantityLabel;
    private JTextField stockQuantityTextField;
    private JLabel deltaInventoryLabel;
    private JTextField deltaInventoryTextField;
    private int agencyId;
    private String inputStockDate;
    private String deliveryForm;
    private String truckingCompany;
    private String supplierGLN;
    private String supplierID;
    private String palletGTIN;
    private String boxGTIN;
    private String buyId;
    private int status;
    private String sSCC;
    private String itemGTIN;
    private String itemId;
    private String itemBatch;
    private String batchPrice;
    private String dLC;
    private String dLUO;
    private String packaging;
    private String unit;
    private String notes;
    private String inputStockQuantity;
    private String inventoryDate;
    private String stockQuantity;
    private String deltaInventory;
    private String lastUpdateUser;
    private String lastUpdateTime;
    private String id;
    private JPanel jPanel1;
    private JPanel jPanel2;
    private JPanel jPanel3;
    private JPanel jPanel4;
    private JPanel jPanel5;
}
